package com.bmp.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.bmp.dao.UserDao;
import com.bmp.model.User;
import com.bmp.model.vo.UserVoGroups;
import com.bmp.service.UserManager;

@Component("userManager")
public class UserManagerImpl implements UserManager {

	private UserDao userDao;

	public UserDao getUserDao() {
		return userDao;
	}

	@Resource
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public boolean isUser(String username, String password) {
		return userDao.checkUserExistsWithLoginInfo(username, password);
	}

	public void addUser(User u) {
		this.userDao.insert(u);
	}

	public void deleteUserById(int id) {
		this.userDao.deleteUserById(id);
	}

	public User getUserById(int id) {
		return this.userDao.getUserById(id);
	}

	public void updateUser(User u) {
		this.userDao.updateUser(u);
	}

	public User getUserByNameAndPassword(String username, String password) {
		return this.userDao.getUserByNameAndPassword(username, password);
	}

	public List<User> getAllUsers() {
		return this.userDao.getAllUsers();
	}

	public int getTotalPages() {
		return this.userDao.getTotalPages();
	}

	public List<UserVoGroups> getUser(int page, int rows) {
		return this.userDao.getUser(page, rows);
	}
	
}
